package controllers;

import java.util.Collection;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import domain.Auction;
import services.AuctionService;


@Controller
@RequestMapping("/auction")
public class AuctionController extends AbstractController{
	
	//Services
		@Autowired
		private AuctionService auctionService;
	

	//Constructors
		public AuctionController(){
			super();
		}
		
	// Listing methods
	//Active auctions
		@RequestMapping(value = "/activeList", method = RequestMethod.GET)
		public ModelAndView list() {
			ModelAndView result;
			Collection<Auction> auctions;
		
			auctions = auctionService.findActiveAuctions();

			result = new ModelAndView("auction/activeList");
			result.addObject("requestURI", "auction/activeList.do");
			result.addObject("backURI", "/welcome/index.do");
			result.addObject("auctions", auctions);
	
			return result;
		}
		

}
